package com.ternnetwork.core.controller;


import java.io.PrintWriter;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ternnetwork.commons.model.http.BaseResponse;
import com.ternnetwork.core.enums.ResourcesType;
import com.ternnetwork.core.enums.RoleType;
import com.ternnetwork.core.service.RescRoleService;
import com.ternnetwork.core.ui.CheckBoxResourcesZtree;




@Controller
@RequestMapping("/core/rescrole/*")
public class RescRoleController {
	
	@Resource
	private RescRoleService rescRoleService;
	
	@RequestMapping("getTreeJSON.htm")
	public @ResponseBody List<CheckBoxResourcesZtree> getTreeJSON(long roleId,RoleType roleType,ResourcesType resourcesType){
		return rescRoleService.getTreeJSON(roleId, roleType, resourcesType);
	}
	
	@RequestMapping("save.htm")
	public @ResponseBody BaseResponse save(long roleId,RoleType roleType,ResourcesType resourcesType,String resourcesIds){
		return rescRoleService.idoSave(roleId, roleType, resourcesType, resourcesIds);
	}
	
	@RequestMapping("updateBatch.htm")
	public  @ResponseBody BaseResponse updateResourcesBatch(long resourcesId,String deleteRoleIds,String addRoleIds){
			rescRoleService.idoUpdateBatch(resourcesId, deleteRoleIds, addRoleIds);
			BaseResponse retResponse=new BaseResponse();
			retResponse.setStatus(1);
			retResponse.setMessage("操作成功!");
			return retResponse;
	}
	
	
}
